/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dotexe.webframework.core.bindings;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author jovan.tomasevic
 */
public class BindingSource extends JSONObject {
    public BindingSource() throws JSONException
    {
        super.put("Name", JSONObject.NULL);
        super.put("Source", JSONObject.NULL);
        super.put("ReadOnly", false);
        super.put("PropertiesToBind", new JSONArray());

    }

    /**
    * Gets or sets the name.
    */
    public String getName() throws JSONException{
        return this.getString("Name");
    }
    public void setName(String name) throws JSONException{
       if(name == null){
            this.put("Name", JSONObject.NULL);
        }
        else{
            this.put("Name", name);
        }
    }
    /**
    * data prepared for client.
    */
    public JSONObject getSource() throws JSONException{
        return (JSONObject) this.get("Source");
    }
    public void setSource(JSONObject source) throws JSONException{
        if(source == null){
            this.put("Source", JSONObject.NULL);
        }
        else{
            this.put("Source", source);
        }
    }
    public void setSource(JSONArray source) throws JSONException{
        if(source == null){
            this.put("Source", JSONObject.NULL);
        }
        else{
            this.put("Source", source);
        }
    }
    /**
    * Indicates that data source can't be updated
    */
    public Boolean getReadOnly() throws JSONException{
        return this.getBoolean("ReadOnly");
    }
    public void setReadOnly(Boolean value) throws JSONException{
        if(value == null){
            this.put("ReadOnly", false);
        }
        else{
            this.put("ReadOnly", value);
        }
    }
    /**
    * Gets or sets the properties to bind.
    */
    public JSONArray getPropertiesToBind() throws JSONException{
        return (JSONArray) this.get("PropertiesToBind");
    }
    public void setPropertiesToBind(JSONArray value) throws JSONException{
        if(value == null){
            this.put("PropertiesToBind", JSONObject.NULL);
        }
        else{
            this.put("PropertiesToBind", value);
        }
    }
}
